﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CodeBuilder
{
    public partial class OptionForm : Form
    {
        public OptionForm()
        {
            InitializeComponent();
        }

        private void OptionForm_Load(object sender, EventArgs e)
        {
            try
            {
                this.txtAuthor.Text = Config.Author;

                this.txtServiceAddress.Text = Config.ServerUrl;

            }
            catch (Exception ex)
            {
                MessageBox.Show("无法加载默认信息！"+ex.Message);
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtAuthor.Text))
            {
                Config.Author = this.txtAuthor.Text;
                Config.ServerUrl = this.txtServiceAddress.Text;

                MessageBox.Show("保存成功。");

                //修改默认地址
                ServiceHost._istance = null;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
    }
}
